package com.example.api;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.event.EventListener;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;


@SpringBootApplication
@EnableScheduling
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
public class ApiApplication {

    public static void main(String[] args) {
        SpringApplication.run(ApiApplication.class, args);
    }


    @EventListener
    public void onApplicationReady(ApplicationReadyEvent event) {
        // 获取应用的端口
        Environment env = event.getApplicationContext().getEnvironment();
        String port = env.getProperty("server.port", "8080");
        String contextPath = env.getProperty("server.servlet.context-path", "");

        // Swagger 文档路径（根据你用的是哪个 Swagger UI 调整）
        String swaggerUrl = "http://localhost:" + port + contextPath + "/doc.html";

        System.out.println("\n----------------------------------------------------------");
        System.out.println("文档地址: " + swaggerUrl);
        System.out.println("----------------------------------------------------------\n");
    }

}
